<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>添加/修改产品</title>
<c:import url="/ctrl/simpleheader"></c:import>
<script type="text/javascript" src="/scripts/product/detail.js"></script>
<link rel="stylesheet" href="/scripts/editor/themes/default/default.css" />
<script type="text/javascript" src="/scripts/editor/kindeditor-min.js"></script>
<script type="text/javascript" src="/scripts/editor/lang/zh_CN.js"></script>
<script>
	var editor_intro,editor_shortintro,editor_others,editor_service;
	var options = {
			resizeType : 1,
			allowPreviewEmoticons : false,
			allowImageUpload : false,
			items : [ 'source', 'fontname', 'fontsize', '|', 'forecolor',
					'hilitecolor', 'bold', 'italic', 'underline',
					'removeformat', '|', 'justifyleft', 'justifycenter',
					'justifyright', 'insertorderedlist', 'insertunorderedlist',
					'|', 'image', 'link' ]
	};
	KindEditor.ready(function(K) {
		editor_intro = K.create('textarea[name="intro"]', options);
		editor_shortintro = K.create('textarea[name="shortIntro"]', options);
		editor_others = K.create('textarea[name="others"]', options);
		editor_service = K.create('textarea[name="service"]', options);		
	});
</script>
<link rel="stylesheet" href="/scripts/ui/jquery.ui.core.css">
<link rel="stylesheet" href="/scripts/ui/jquery.ui.theme.css">
<link rel="stylesheet" href="/scripts/ui/jquery.ui.datepicker.css">
<script src="/scripts/ui/jquery.ui.core.min.js"></script>
<script src="/scripts/ui/jquery.ui.datepicker.min.js"></script>
<script>
	$(function() {
		$("#begin").datepicker({
			dateFormat : "yy-mm-dd",
			minDate : 0,
			maxDate : "+1Y",
			changeMonth : true,
			changeYear : true,
			onClose : function(selectedDate) {
				$("#end").datepicker("option", "minDate", selectedDate);
			}
		});
		$("#end").datepicker({
			dateFormat : "yy-mm-dd",
			minDate : 0,
			maxDate : "+1Y",
			changeMonth : true,
			changeYear : true,
			onClose : function(selectedDate) {
				$("#begin").datepicker("option", "maxDate", selectedDate);
			}
		});
	});
</script>
</head>
<body>
  <div title="产品信息">
    <div style="padding: 10px 0 10px 60px">
      <form id="ff" method="post">
        <table>
          <tr>
            <td style="width: 100px;">产品种类:</td>
            <td><select id="type" name="type"><option
                  value=""></option>
                <c:forEach var="insType" items="${insTypeList}">
                  <option value="<c:out value="${insType.index}" />"
                    <c:if test="${product.productTypeFid==insType.index}">selected="selected"</c:if>><c:out
                      value="${insType.name}" /></option>
                </c:forEach></select></td>
          </tr>
          <tr>
            <td>保险公司:</td>
            <td><select id="company" name="company"><option
                  value=""></option>
                <c:forEach var="company" items="${companyList}">
                  <option value="<c:out value="${company.companyId}" />"
                    <c:if test="${product.productInsFid==company.companyId}">selected="selected"</c:if>><c:out
                      value="${company.companyShortName}" /></option>
                </c:forEach></select></td>
          </tr>
          <tr>
            <td>供应商:</td>
            <td><select id="sup" name="sup"><option
                  value=""></option>
                <c:forEach var="sup" items="${supList}">
                  <option value="<c:out value="${sup.supId}" />"
                    <c:if test="${product.productSupFid==sup.supId}">selected="selected"</c:if>><c:out
                      value="${sup.supName}" /></option>
                </c:forEach></select></td>
          </tr>
          <tr>
            <td>产品名称:</td>
            <td><input type="text" id="name" name="name"
              value="<c:out
                      value="${product.productName}" />"
              style="width: 300px;"></input></td>
          </tr>
          <tr>
            <td>产品图片:</td>
            <td><input type="text" id="pic" name="pic"
              value="<c:out
                      value="${product.productPic}" />"></input></td>
          </tr>
          <tr>
            <td>产品代码:</td>
            <td><input type="text" id="code" name="code"
              value="<c:out
                      value="${product.productCode}" />"></input></td>
          </tr>
          <tr>
            <td>产品简称:</td>
            <td><input type="text" id="shortName" name="shortName"
              value="<c:out
                      value="${product.productShortName}" />"
              style="width: 300px;"></input></td>
          </tr>
          <tr>
            <td>产品有效期:</td>
            <td><fmt:formatDate var="productBeginTime"
                pattern="yyyy-MM-dd" value="${product.productBeginTime}" />
              <fmt:formatDate var="productEndTime" pattern="yyyy-MM-dd"
                value="${product.productEndTime}" /><input id="begin"
              name="begin" style="width: 100px" class="date-pick"
              value="<c:out
                      value="${productBeginTime}" />" />&nbsp;-&nbsp;
              <input id="end" name="end" class="date-pick"
              style="width: 100px"
              value="<c:out
                      value="${productEndTime}" />" /></td>
          </tr>
          <tr>
            <td>产品价格:</td>
            <td><input type="text" id="price" name="price"
              value="<c:out
                      value="${product.productPrice}" />"></input></td>
          </tr>
          <tr>
            <td>结算金额:</td>
            <td><input type="text" id="settlePrice"
              name="settlePrice"
              value="<c:out
                      value="${product.productSettlePrice}" />"></input></td>
          </tr>
          <tr>
            <td>可购限额:</td>
            <td><input type="text" id="quota" value="1"
              name="quota"
              value="<c:out
                      value="${product.productQuota}" />"></input></td>
          </tr>
          <tr>
            <td>承保最小年龄:</td>
            <td><input type="text" id="min" name="min"
              value="<c:out
                      value="${product.productAgeMin}" />"></input></td>
          </tr>
          <tr>
            <td>承保最大年龄:</td>
            <td><input type="text" id="max" name="max"
              value="<c:out
                      value="${product.productAgeMax}" />"></input></td>
          </tr>
          <tr>
            <td>时间:</td>
            <td><input type="text" id="time" name="time"
              value="<c:out
                      value="${product.productTime}" />"></input><select
              id="timeUnit" name="timeUnit"><option value="D"
                  <c:if test="${product.productTimeUnit=='D'}">selected="selected"</c:if>>天</option>
                <option value="M"
                  <c:if test="${product.productTimeUnit=='M'}">selected="selected"</c:if>>月</option>
                <option value="Y"
                  <c:if test="${product.productTimeUnit=='Y'}">selected="selected"</c:if>>年</option></select></td>
          </tr>
          <tr>
            <td>时间说明:</td>
            <td><input type="text" id="timeDesc" name="timeDesc"
              value="<c:out
                      value="${product.productTimeDesc}" />"
              style="width: 300px;"></input></td>
          </tr>
          <tr>
            <td>产品简介:</td>
            <td><textarea id="shortIntro" name="shortIntro"
                style="width: 700px; height: 200px; visibility: hidden;"><c:out
                  value="${product.productShortIntro}" escapeXml="false" /></textarea></td>
          </tr>
          <tr>
            <td>产品介绍:</td>
            <td><textarea id="intro" name="intro"
                style="width: 700px; height: 200px; visibility: hidden;"><c:out
                  value="${product.productIntro}" escapeXml="false" /></textarea></td>
          </tr>
          <tr>
            <td>服务说明:</td>
            <td><textarea id="service" name="service"
                style="width: 700px; height: 200px; visibility: hidden;"><c:out
                  value="${product.productServeDesc}" escapeXml="false" /></textarea></td>
          </tr>
          <tr>
            <td>其他说明:</td>
            <td><textarea id="others" name="others"
                style="width: 700px; height: 200px; visibility: hidden;"><c:out
                  value="${product.productOthers}" escapeXml="false" /></textarea></td>
          </tr>
          <tr>
            <td>状态:</td>
            <td><select id="status" name="status">
                <c:forEach var="status" items="${statusList}">
                  <option value="<c:out value="${status.index}" />"
                    <c:if test="${product.productIsActive==status.index}">selected="selected"</c:if>><c:out
                      value="${status.name}" /></option>
                </c:forEach></select></td>
          </tr>
        </table>
      </form>
    </div>
    <div style="text-align: center; padding: 5px">
      <c:choose>
        <c:when test="${product.productId!=null}">
          <a href="javascript:void(0)"
            onclick="submitModify('<c:out
              value="${product.productId}" />')">保存</a>
        </c:when>
        <c:otherwise>
          <a href="javascript:void(0)" onclick="submitCreate()">添加产品</a>
        </c:otherwise>
      </c:choose>
    </div>
  </div>
</body>
</html>